/// @tags:
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 2e5 + 2;

char str[maxn];

int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> (str + 1);
    int n = strlen(str + 1);
    int a = 0, b = 0;
    bool flag = false;
    for (int i = 2; i < n; ++i) {
      if (str[i] == 'a') {
        a = i - 1, b = i + 1;
        flag = true;
      }
    }
    if (!flag) {
      a = 1, b = n;
    }
    if (a != 0 && b != 0) {
      for (int i = 1; i <= a; ++i) {
        cout << str[i];
      }
      cout << ' ';
      for (int i = a + 1; i < b; ++i) {
        cout << str[i];
      }
      cout << ' ';
      for (int i = b; i <= n; ++i) {
        cout << str[i];
      }
      cout << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("A. Gardener and the Capybaras.in", "r", stdin);
  freopen("A. Gardener and the Capybaras.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
